﻿#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    timer=new QTimer(this);
    timer->setInterval(50);
    timer->setTimerType(Qt::CoarseTimer);
    connect(timer,SIGNAL(timeout()),this,SLOT(updateProgress()));

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::updateProgress()
{
    int value=ui->progressBar->value()+1;
    if(value==100)
    {
        value=0;
    }
    ui->progressBar->setValue(value);
}


void MainWindow::on_pushButton_clicked()
{
    timer->start();
}

void MainWindow::on_pushButton_2_clicked()
{
    timer->stop();
}
